<!DOCTYPE html>
<html class="am-touch js cssanimations">
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>服务项目选择</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <meta name="renderer" content="webkit" />
    <link rel="icon" type="image/png" href="../../assets/i/favicon.png" />
    <link rel="stylesheet" href="../../assets/css/amazeui.min.css" />
    <link rel="stylesheet" href="../../assets/css/basic.css" />
    <link rel="stylesheet" href="../../assets/css/app.css" />
    <style>
        header, header div{ height: 44px !important; }
        header div a{ display: inline-block; height: 44px !important; line-height: 44px; font-size: 1.8rem; }
        header h1{ padding: 8px; }
        h2{ margin: 0.5em 0 0.5em 0.5em; }
        p{ color: #000; }
        .am-list li p{ display: inline-block; margin: 0; }
        .am-list li{ padding: 0.6em 1em 1em; }
        .am-a{ display: inline-block !important; padding: 0 !important; }
    </style>
</head>
<body>
<header class="am-header am-header-default">
    <div class="am-header-left am-header-nav">
        <a href="#" class=""><i class="icon-left"></i>返回</a>
    </div>
</header>

<section id="kuaikuai-pay">
        <!--列表标题-->
        <div class="am-list-news am-list-news-default">
            <div class="am-list-news-hd am-cf">
                <h2>服务项目</h2>
            </div>
        </div>
        <div class="am-list-news-bd">
            <ul class="am-list">
                <li class="am-g">
                    <a class="am-a">
                        <i class="r-btn rg"></i>
                        <p class="am-btn-sm">快快极致打蜡洗车</p>
                    </a>

                    <p class="am-text-lg option am-fr">
                        <a class="btn-del minus" onclick="minus(this)">-</a>
                        <input type="text" class="fm-txt number" value="2" />
                        <a class="btn-add plus" onclick="plus(this)">+</a>
                    </p>
                </li>

                <li class="am-g">
                    <a class="am-a">
                        <i class="r-btn"></i>
                        <p class="am-btn-sm">快快极致打蜡洗车</p>
                    </a>

                    <p class="am-text-lg option am-fr">
                        <a class="btn-del minus">-</a>
                        <input type="text" class="fm-txt number" value="0" />
                        <a class="btn-add plus">+</a>
                    </p>
                </li>

                <li class="am-g">
                    <a class="am-a">
                        <i class="r-btn rg"></i>
                        <p class="am-btn-sm">快快极致打蜡洗车</p>
                    </a>

                    <p class="am-text-lg option am-fr">
                        <a class="btn-del minus" onclick="minus(this)">-</a>
                        <input type="text" class="fm-txt number" value="2" />
                        <a class="btn-add plus" onclick="plus(this)">+</a>
                    </p>
                </li>
            </ul>
        </div>
</section>

<section class="kuaikuai-btn kuaikuai-btn-lg am-topbar-fixed-bottom" id="quan">
    <button type="submit" class="btn am-btn am-btn-success am-btn-lg am-btn-block">提交</button>
</section>
<!--[if (gte IE 9)|!(IE)]><!-->
<script src="../../assets/js/jquery.min.js" type="text/javascript"></script>
<!--<![endif]-->
<!--[if lte IE 8 ]>
<script src="../../assets/js/jquery.min-1.11.1.js" type="text/javascript"></script>
<![endif]-->
<script src="../../assets/js/amazeui.min.js" type="text/javascript"></script>
<script src="../../assets/js/amazeui.widgets.helper.min.js" type="text/javascript"></script>
<script src="../../assets/js/handlebars.min.js" type="text/javascript"></script>
<script src="../../assets/js/kuaikuai.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        $('li.am-g a.am-a').each(function () {
            var aTxt = $(this).parent().find('input.fm-txt');
            var oAdd = $(this).parent().find('a.btn-add');
            var oDel = $(this).parent().find('a.btn-del');

            if (aTxt.val() == '0') {
                aTxt.attr({ 'disabled':'disabled' });
            }


            //  按钮选中事件
            $(this).on('click', function () {
                $(this).find('i.r-btn').toggleClass('rg');

                var iBtn = $(this).find('i.r-btn');
                if ($(iBtn).hasClass('rg')) {
                    aTxt.removeAttr('disabled').val('1');
                    oAdd.attr({ 'onclick': 'plus(this)'} );
                    oDel.attr({ 'onclick': 'minus(this)'} );
                } else {
                    aTxt.attr({ 'disabled':'disabled' }).val('0');
                    oAdd.removeAttr('onclick');
                    oDel.removeAttr('onclick');
                }
            });
        });

        allInput();
    });

    /*
    * 获取选中列表里面的input数值
    * @return input里面的数值，以数组形式返回
    * */
    function allInput () {
        var arrLi = new Array();
        var oLi = $('li.am-g');
        for (var i = 0; i < oLi.length; i++) {
            if ($(oLi[i]).find('i').hasClass('rg')) {
                arrLi.push($(oLi[i]).find('input.fm-txt').val());
            }
        }
        return arrLi;
    }

    //  减少
    function minus (obj) {
        $number = $(obj).parent().find('.number').val();
        if($number > 1) {
            $number--;
        } else {
            $number = 0;
            if ($number == '0') {
                $(obj).parent().find('.number').attr({ 'disabled':'disabled' });
            }
        }
        $(obj).parent().find('.number').val($number);
    }

    // 添加
    function plus (obj) {
        $number = $(obj).parent().find('.number').val();
        $number++;
        $(obj).parent().find('.number').val($number);
    }
</script>
</body>
</html>